package com.mxx.exceltoentity.ui;

import com.mxx.exceltoentity.util.SimpleConfigUtil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class SettingUI {
    private JTextField appidField;
    private JPanel mainPanel;
    private JPanel settingPanel;
    private JLabel linklabel;
    private JPasswordField passwordField;

    public SettingUI() {
        this.appidField.setText(SimpleConfigUtil.getString("key"));
        this.passwordField.setText(SimpleConfigUtil.getString("value"));
    }

    public JComponent getComponent() {
        return mainPanel;
    }

    public JTextField getAppidField() {
        return appidField;
    }

    public JPasswordField getPasswordField() {
        return passwordField;
    }

    private void createUIComponents() {
        linklabel = new JLabel("<html><a href='http://api.fanyi.baidu.com/api/trans/product/desktop?req=developer'>百度翻译</a></html>");
        linklabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        linklabel.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent e) {
                try {
                    Runtime.getRuntime().exec("cmd.exe /c start " + "http://api.fanyi.baidu.com/api/trans/product/desktop?req=developer");
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
    }
}
